import mongoose from "mongoose";


const Schema = mongoose.Schema;

const moviesSchema = new Schema({
  name: String,
  url: String
});

const Movies = mongoose.model("Movie", moviesSchema);

Movies.findOne().then(data => {
  if (!data) {
    const newMovies = new Movie({
      name: "暂无数据",
      url: "http://www.baidu.com"
    });
    newMovies.save();
  }
}).catch(err => {
  throw new Error(err);
});

export default Movies;